<template>
  <div class="about-author sec-card">
    <div class="about-author-desc section-header">
      👨‍💻 关于作者
    </div>
    <div class="about-author-info">
      <div class="author-name">
        <router-link :to="{ path: `/member/${user.username}/home` }">
          {{ user.alias }} <span>{{ '@' + user.username }}</span>
        </router-link>
      </div>
      <div class="info-show">
                    <span class="article-count">
                        {{ user.topicCount }} 文章
                    </span>
        <span class="follower-count">
                        {{ user.followerCount }} 粉丝
                    </span>
      </div>
      <div class="follow-btn">
        <div class="follow-btn-item">
          关注
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {hasFollow } from '@/api/follow'
export default {
  name: 'Author',
  props: {
    user: {
      type: Object,
      default: null
    }
  },
  data() {
    return {
      hasFollow: false
    }
  },
  mounted() {
    this.fetchInfo()
  },

  methods: {
    fetchInfo() {
      if(this.token != null && this.token !== '')
      {
        hasFollow(this.user.id).then(value => {
          const { data } = value
          this.hasFollow = data.hasFollow
        })
      }
    }
  }
}
</script>

<style scoped>
.about-author-info{
  padding-bottom: 8px;
}
.author-name{
  display: flex;
  justify-content: center;
  font-size: 16px;
  font-weight: bold;
  padding: 20px;
}

.info-show{
  display: flex;
  justify-content: space-around;
  font-size: 14px;
  margin-bottom: 10px;
}

.follow-btn{
  margin: auto;
  display: flex;
  justify-content: space-around;
  padding: 10px;
  background-color: deepskyblue;
  width: 60%;
}
</style>
